#ifndef __QUEUE_G_DEFINE__
#define __QUEUE_G_DEFINE__

#define BV(x) (1<<x)

#define QUEUE_PROJECT_NAME     "HttpQueue"
#define QUEUE_PEOJECT_VERSION  "0.3.0 alpha"

#ifndef QUEUE_DATA_DIR
#define QUEUE_DATA_DIR "./"
#endif

#ifndef QUEUE_DEFAULT_NAME
#define QUEUE_DEFAULT_NAME "queue"
#endif

#define QUEUE_DEFAULT_DATA_PATH "data"
#define QUEUE_DEFAULT_LOG_DIR   "logs"
#define QUEUE_DEFAULT_CONF      "conf/queued.conf"

#ifndef MAX_FILE_SIZE
#define MAX_FILE_SIZE BV(30)
#endif

#define FILE_PATH_SIZE 128

#define QUEUE_RUNING   0
#define QUEUE_EXIT     1

#define QUEUE_CMD_NULL     0
#define QUEUE_CMD_HTTP     BV(1)
#define QUEUE_CMD_SHM      BV(2)
#define QUEUE_CMD_MSG      BV(3)
#define QUEUE_CMD_FIFO     BV(4)
#define QUEUE_CMD_DB       BV(5)
#define QUEUE_CMD_INNER    BV(6)
#define QUEUE_CMD_EXTER    BV(7)

#define QUEUE_INDEX_NONE     -1
#define QUEUE_INDEX_HTTP     0
#define QUEUE_INDEX_SHM      1
#define QUEUE_INDEX_MSG      2
#define QUEUE_INDEX_FIFO     3
#define QUEUE_INDEX_DB       4
#define QUEUE_INDEX_INNER    5
#define QUEUE_INDEX_EXTER    6

#define QUEUE_EXT_HTTP   "http"
#define QUEUE_EXT_SHM    "shm"
#define QUEUE_EXT_MSG    "msg"
#define QUEUE_EXT_FIFO   "fifo"
#define QUEUE_EXT_DB     "db"
#define QUEUE_EXT_INNER  "inner"
#define QUEUE_EXT_EXTER  "exter"

#define QUEUE_PATH_HTTP   "/w."QUEUE_EXT_HTTP
#define QUEUE_PATH_SHM    "/w."QUEUE_EXT_SHM
#define QUEUE_PATH_MSG    "/w."QUEUE_EXT_MSG
#define QUEUE_PATH_FIFO   "/w."QUEUE_EXT_FIFO
#define QUEUE_PATH_DB     "/w."QUEUE_EXT_DB
#define QUEUE_PATH_INNER  "/w."QUEUE_EXT_INNER
#define QUEUE_PATH_EXTER  "/w."QUEUE_EXT_EXTER
#define QUEUE_PATH_DEAULT "/w."

typedef enum _queue_error
{
	QERR_COMMON = -1000,
	QERR_OPEN_FILE     ,
	QERR_MEM_FAIL      ,
	QERR_GET_SEM       ,
	QERR_GET_SHM       ,
	QERR_HARD_DISK     ,
	QERR_RENAME_FILE   ,
	QERR_SEEK_FILE     ,
	QERR_LOCK_RQ       ,
	QERR_MSYNC         ,
	QERR_CMD_UNKNOWN   ,
	Q_EXEC_OK = 1
}
QueueErr;

typedef enum _command_enum
{
	CMD_NULL = 0   ,
	CMD_RESTART    ,
	CMD_START_HTTP ,
	CMD_STOP_HTTP  ,
	CMD_START_SHM  ,
	CMD_STOP_SHM   ,
	CMD_START_MSG  ,
	CMD_STOP_MSG   ,
	CMD_START_FIFO ,
	CMD_STOP_FIFO  ,
	CMD_START_DB   ,
	CMD_STOP_DB    ,
	CMD_START_INNER,
	CMD_STOP_INNER ,
	CMD_START_EXTER,
	CMD_STOP_EXTER ,
	CMD_INFO       ,
	CMD_STOP = 10000
}
Command;

#endif // __QUEUE_G_DEFINE__
